package com.one.shopping.ui.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.one.shopping.AppContext;
import com.one.shopping.R;
import com.one.shopping.entity.Users;
import com.one.shopping.ui.baseFragment.BaseFragment;

/**
 * @author 柯尊诚
 * @version 1.0
 * @date 创建时间：2016/1/13 17:47
 */
public class UserDetailFragment extends BaseFragment{

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.user_detail_fragment, container, false);
        Users users = AppContext.getInstance().getLoginInfo();
        ((TextView)view.findViewById(R.id.user_detail_id_values_tv)).setText(""+users.getId());
        ((TextView)view.findViewById(R.id.user_detail_name_values_tv)).setText(users.getName());
        TextView typeValues = (TextView)view.findViewById(R.id.user_detail_type_values_tv);
        if (users.getType() == 0)
            typeValues.setText("管理员");
        else
            typeValues.setText("收银员");

        ((Button)view.findViewById(R.id.user_loginout_btn)).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                AppContext.getInstance().cleanLoginInfo();
                AppContext.showLoginActivity(getActivity());
                getActivity().finish();
            }
        });
        return view;
    }
}
